package cate.game.role.pvp.teampvp.msg;

import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTeamPvp;
import cate.game.pvp.teampvp.dto.TeamPvpTeamData;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "组队竞技 邀请处理的请求")
public class TeamPvpInviteAnswerReq implements MsgInput {
    @NoteField("邀请人uid")
    public String leaderUid;

    @NoteField("同意/拒绝")
    public boolean ok;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        GameResult<TeamPvpTeamData> answerRes = game.pvp.teamPvp.inviteAnswer(cc.getRole(), leaderUid, ok);
        if (!answerRes.ok()) {
            game.notice.message(cc.getRole(), answerRes);
            return;
        }
        if (ok) {
            cc.sendNow(new TeamPvpDataResp(cc.getRole(), answerRes.data));
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBTeamPvp.INVITE_ANSWER_REQ;
    }
}
